package com.apiConfig;

import com.alibaba.dubbo.config.ApplicationConfig;
import com.alibaba.dubbo.config.ProtocolConfig;
import com.alibaba.dubbo.config.RegistryConfig;
import com.alibaba.dubbo.config.ServiceConfig;
import com.service.DemoService;
import com.service.DemoServiceImpl;

import java.io.IOException;

/**
 * Created by pengfei on 16/7/6.
 */
public class ApiProvider {
    public static void main(String[] args) throws IOException {
        DemoService demoService = new DemoServiceImpl();
        ApplicationConfig application = new ApplicationConfig();
        application.setName("wocao");

        RegistryConfig registry = new RegistryConfig();
        registry.setAddress("zookeeper://localhost:2181");

        ProtocolConfig protocol = new ProtocolConfig();
        protocol.setName("dubbo");
        protocol.setPort(20881);

        ServiceConfig<DemoService> service = new ServiceConfig<DemoService>();
        service.setApplication(application);
        service.setProtocol(protocol);
        service.setRegistry(registry);
        service.setInterface(DemoService.class);
        service.setRef(demoService);
        service.setVersion("1.0.0");

        service.export();

        System.in.read();
    }
}
